package gg.zsw.datasource.demo.kafka;

import gg.zsw.dataframework.pubsub.AbstractObserver;
import gg.zsw.dataframework.pubsub.AbstractSubject;
import org.apache.kafka.clients.consumer.ConsumerRecord;

/**
 * 发布String类型的消息，约束观察者为AbstractObserver<String>
 *
 * @author zhou.sw
 * @Date 2020/6/30 10:53
 */
public class MessageTopic<Observer extends AbstractObserver<String>> extends AbstractSubject<Observer, String> {

    /**
     * 起到分类器的作用
     *
     * @param consumerRecord
     */
    public void handle(ConsumerRecord<String, String> consumerRecord) {
        String messageId = consumerRecord.key();
        String messageKey = consumerRecord.value();
        notifyKey(messageId, messageKey);
    }

    @Override
    protected void notify(String s) {

    }
}
